package com.ts.enterprise.rest.worker;


import com.ts.enterprise.common.annotation.LoginRequired;
import com.ts.enterprise.common.consts.Constant;

import com.ts.enterprise.common.query.BaseIdQuery;
import com.ts.enterprise.common.response.ApiResult;
import com.ts.enterprise.module.user.query.SmsSendQuery;
import com.ts.enterprise.module.user.query.WorkerTagUpdateQueryDTO;
import com.ts.enterprise.module.user.query.update.WorkerInfoUpdateQuery;
import com.ts.enterprise.module.user.query.update.WorkerTagUpdateQuery;
import com.ts.enterprise.module.user.service.MpUserService;
import com.ts.enterprise.module.user.service.WorkerInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dean
 * @since 2021-10-18
 */
@RestController
@RequestMapping(Constant.API_MP + "/worker")
@Api(tags = "小程序用户接口")
public class MpWorkerController {

     @Autowired
     private MpUserService mpUserService;

     @Autowired
     private WorkerInfoService workerInfoService;


     @ApiOperation("测试登录接口")
     @RequestMapping(value = "/testLogin", method = RequestMethod.POST)
     public ApiResult<String> testLogin(@RequestBody BaseIdQuery query) {
          return ApiResult.success(mpUserService.testLogin(query.getId()));
     }

     @ApiOperation("短信登录接口")
     @PostMapping("/smsLogin")
     public ApiResult<String> smsLogin(@RequestBody SmsSendQuery query) {
          return ApiResult.success(mpUserService.smsLogin(query));
     }

     @LoginRequired
     @ApiOperation("获取token中个人资料")
     @PostMapping("/getUserInfoByToken")
     public ApiResult<Object> getUserInfoByToken() {
          return ApiResult.success(workerInfoService.getDetailById());
     }

     @LoginRequired
     @ApiOperation("阿姨更新基础信息")
     @PostMapping("/updateInfo")
     public ApiResult<Object> updateInfo(@Validated @RequestBody WorkerInfoUpdateQuery query) {
          return ApiResult.success(workerInfoService.updateInfo(query));
     }

     @LoginRequired
     @ApiOperation("阿姨更新员工标签")
     @PostMapping("/updateWorkTag")
     public ApiResult<Object> updateWorkTag(@Validated @RequestBody WorkerTagUpdateQueryDTO query) {
          return ApiResult.success(workerInfoService.updateWorkTag(query));
     }




}

